package com.itheima.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.mapper.PmsMemberPriceMapper;
import com.itheima.pojo.db.PmsMemberPrice;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PmsMemberPriceApiImpl implements PmsMemberPriceApi {
    @Autowired
    private PmsMemberPriceMapper pmsMemberPriceMapper;

    @Override
    public void insertList(List<PmsMemberPrice> list, Long productId) {
        for (PmsMemberPrice pmsMemberPrice : list) {
            pmsMemberPrice.setId(null);
            pmsMemberPrice.setProductId(productId);
            pmsMemberPriceMapper.insert(pmsMemberPrice);
        }
    }

    @Override
    public void deleteById(Long id) {
        pmsMemberPriceMapper.delete(new LambdaQueryWrapper<PmsMemberPrice>().eq(PmsMemberPrice::getProductId,id));
    }

    @Override
    public List<PmsMemberPrice> selectByPId(Long id) {
        return pmsMemberPriceMapper.selectList(new LambdaQueryWrapper<PmsMemberPrice>().eq(PmsMemberPrice::getProductId,id));
    }
}
